package com.blast.manager.blast.presenter

import android.view.KeyEvent
import com.blast.manager.R
import com.blast.manager.net.presenter.AbsNetCheckPresenter
import com.blast.manager.net.presenter.NetCheckReadyPresenter
import com.wxl.common.life.ViewModelQuick
import kotlinx.android.synthetic.main.layout_blast_ready.view.*

class BlastReadyPresenter : AbsNetCheckPresenter() {

    override fun showView(vararg args: Any) {
        getBlastActivity().dismissButtonLayout()
        rootView.blastReadyNot.setOnClickListener {
            getBlastActivity().finish()
        }
        rootView.blastReadySure.setOnClickListener {
            ViewModelQuick.get(getBlastActivity(),NetCheckReadyPresenter::class.java).show(true)
        }
    }

    override fun getLayoutResId(): Int {
        return R.layout.layout_blast_ready
    }

    override fun onKeyDownEvent(keyCode: Int, event: KeyEvent?): Boolean {
        if(isAdd()){
            if(keyCode == KeyEvent.KEYCODE_F1 || keyCode == KeyEvent.KEYCODE_BACK){
                rootView.blastReadyNot.performClick()
            }
            if(keyCode == KeyEvent.KEYCODE_F4 || keyCode == KeyEvent.KEYCODE_ENTER){
                rootView.blastReadySure.performClick()
            }
        }
        return super.onKeyDownEvent(keyCode, event)
    }
}